﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BusinessComponents.Managers;
using BusinessComponents;

namespace WaterfrontLodge.WebForms.RoomMgt
{
    public partial class RoomSearch : System.Web.UI.Page
    {
        #region Declaration
        IRoomTypeMgr typeMgr = ManagerFactory.RoomTypeMgr;
        #endregion

        #region PageLoad
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                List<RoomType> typeList = typeMgr.FindAllRoomTypes().ToList();
                ListItem li = new ListItem("All Type", "0");
                dblRoomType.Items.Add(li);
                for (int i = 1; i <= typeList.Count; i++)
                {
                    li = new ListItem(typeList[i - 1].Description, typeList[i - 1].TypeCode.ToString());
                    dblRoomType.Items.Add(li);
                }
                dblRoomType.DataBind();
                dblRoomType.Items[0].Selected = true;
            }
        }
        #endregion

        #region Search
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            string roomNo = txtRoomNo.Text;

            if (String.IsNullOrEmpty(roomNo))
            {
                Response.Redirect("~/WebForms/Room/RoomView.aspx?RoomType=" + dblRoomType.SelectedValue + "&RoomStatus=" + rdbStatus.SelectedValue);
            }
            else
            {
                Response.Redirect("~/WebForms/Room/RoomView.aspx?RoomType=" + dblRoomType.SelectedValue + "&RoomStatus=" + rdbStatus.SelectedValue + "&RoomNo=" + roomNo);
            }

        }
        #endregion

        protected void bthShowAll_Click(object sender, EventArgs e)
        {
            Response.Redirect("~/WebForms/Room/RoomView.aspx");
        }
    }
}